TARGET=$1
DIR=./controller/static
if [[ -z "$TARGET" ]]; then
   TARGET=dproxy
fi
if [ ! -f ./controller/static/index.html ]; then
    echo "download static resource"
    wget -O static.zip https://gitee.com/yysf_xin/dproxy/releases/download/v2.0.0/static.zip
    unzip -o static.zip -d $DIR
fi
killall $TARGET
go build -ldflags "-s -w" -o ./bin/$1 gitee.com/yysf-xin/dproxy/cmd/$TARGET
cp -f ./bin/$TARGET /usr/local/bin
